{extend name="public:base"}
{block name='css'}
{/block}

{block name='body'}
<div class="view view-main white-navbar white-toolbar">
    <div data-name="home" class="page">

        <div class="navbar">
            <div class="navbar-inner">
                <div class="left"><a href="{$my_prev_url|default='/'}" class="external"><i class="iconfont icon-fanhui"></i></a></div>
                <div class="center"><span>提现</span></div>
                <div class="right"></div>
            </div>
        </div>

        <div class="page-content padding-bottom50">

            <form name="form" action=""  method="post" id="form">
                <input type="hidden" name="user_type" value="{:input('user_type', 0, 'intval')}"/>
                <div class="chongzhi">
                    <span class="sp1">￥</span>
                    <input type="number" name="amount" placeholder="请输入提现金额..."/>
                    <span class="sp2">{$balance}</span>
                </div>

                <div class="list inline-labels no-hairlines-md" style="margin-top:15px;">
                    <ul>
                        <li class="item-content item-input">
                            <div class="item-inner">
                                <div class="item-title item-label">选择银行</div>
                                <div class="item-input-wrap">
                                    <select name="bank">
                                        <option value="">请选择银行</option>
                                        {volist name='bank_list' id='vo'}
                                        <option value="{$vo}">{$vo}</option>
                                        {/volist}
                                    </select>
                                </div>
                            </div>
                        </li>
                        <li class="item-content item-input">
                            <div class="item-inner">
                                <div class="item-title item-label">银行卡号</div>
                                <div class="item-input-wrap">
                                    <input type="text" name="card" placeholder="请输入银行卡号">
                                    <span class="input-clear-button"></span>
                                </div>
                            </div>
                        </li>
                        <li class="item-content item-input">
                            <div class="item-inner">
                                <div class="item-title item-label">真实姓名</div>
                                <div class="item-input-wrap">
                                    <input type="text" name="name" placeholder="请输入银行卡账户真实姓名">
                                    <span class="input-clear-button"></span>
                                </div>
                            </div>
                        </li>
                    </ul>
                </div>

                <div class="block">
                    <p class="row segmented-round">
                        <button class="col button button-big button-fill " style="background:#66ba61;">提交</button>
                    </p>
                </div>
            </form>

        </div>


    </div>
</div>
{/block}

{block name="js"}
<script>
    var ajaxOn = false ;
    $().ready(function () {
        $("#form").validate({
            rules: {
                money: {
                    required: true,
                    number:true ,
                    min:{$min_withdraw_amount}
                },
                bank : "required" ,
                card : "required" ,
                name : "required"
            },
            messages: {
                money: {
                    required: "请输入提现金额",
                    number: "请输入正确的金额",
                    min: "最少提现金额为{$min_withdraw_amount}元"
                },
                bank : '请选择提现银行' ,
                card : "请输入银行卡号" ,
                name : "请输入银行卡账户的真实姓名"
            },
            showErrors: function (errorMap, errorList) {
                $.each(errorList, function (i, v) {
                    messageToast( v.message );
                    return false;
                });
            },
            onfocusout: false,
            onsubmit : true ,
            onkeyup : false ,
            onclick : false ,
            focusInvalid:false,
            submitHandler:function(form){
                if (ajaxOn) {
                    return false ;
                }
                ajaxOn = true ;
                $.post('', $('#form').serialize(), function(data){
                    messageToast(data.info);
                    if (data.status == 'y') {
                        setTimeout(function(){
                            /*{if condition="input('user_type', 0, 'intval') eq 1"}*/
                            self.location = "{:url('business')}";
                            /*{else/}*/
                            self.location = "{:url('wallet')}";
                            /*{/if}*/
                        },1000);
                    }
                    ajaxOn = false;
                }, 'json');

                return false ;

            }
        });
    });
</script>
{/block}